import { defineStore } from 'pinia'
import apiServe from '@/api'

export const useUserStore = defineStore('user', {
  state: () => ({
    id: '',
    username: '',
    role: ''
  }),
  actions: {
    resetState() {
      this.$reset()
    },
    // 获取用户信息
    async getInfo() {
      return apiServe.user.getUserInfo().then((res) => {
        Object.assign(this, res)
      })
    },
  },
  persist: false,
})
